package com.ycb.bookserver.mapper;

import com.book.constant.AutoFillConstant;
import com.book.enumeration.OperationType;
import com.ycb.book.entity.Category;
import com.ycb.bookserver.annotation.AutoFill;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("select * from category where id=#{id}")
    Category getById(Long id);

    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into category (name,sort,status) values (#{name},#{sort},#{status})")
    void insert(Category category);

    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    @Select("select * from category")
    List<Category> list();
}
